package com.cskaoyan.controller.wx_collect;

import com.cskaoyan.bean.BaseParam;
import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.PageDataVo;
import com.cskaoyan.service.wx_collect.CollectService;
import com.cskaoyan.utils.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @description:
 * @author: enhui
 **/
@RestController
@RequestMapping("wx/collect")
public class WxCollectController {
    @Autowired
    CollectService collectService;

    @RequestMapping("list")
    public BaseRespVo collectList(Integer type, BaseParam param) {
        PageDataVo collectList = collectService.collectList(type, param);
        return BaseRespVo.ok(collectList);
    }

    @RequestMapping("addordelete")
    public BaseRespVo addCollect(@RequestBody Map map) {
        Integer type = (Integer) map.get("type");
        Integer valueId = (Integer) map.get("valueId");
        int code = collectService.addCollect(type, valueId);
        if (code == Constant.SUCCESS) {
            return BaseRespVo.ok();
        }
        return BaseRespVo.error("添加收藏失败");
    }
}
